package repository.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import repository.EventRepository;
import domain.Event;
import domain.User;


@Repository
public class EventRepositoryImpl extends AbstractHibernateRepository<Event> implements EventRepository {

	@Autowired
	public EventRepositoryImpl(SessionFactory sessionfactory){
		super(sessionfactory);
	}

	@Override
	public Event get(int id) {
		return get(Event.class, id);
	}
	
	@Override
	public void save(Event event) {
		super.save(event);
	}

	@Override
	public List<Event> getEventsByUser(User user) {
		String hql = "FROM Event WHERE creator=?";
		return find(hql, user);
	}
	
	@Override
	public void delete(Event e) {
		super.delete(e);
	}

}